﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SalesSys.Comm.BLL;
using SalesSys.Comm.Utility;

namespace SalesSys.WebCore
{
    public class ViewDto
    {
        public static ViewDto<T> Create<T>(T data)
        {
            return new ViewDto<T>(){Data=data};
        }
        public static ViewDtos<T> CreateList<T>(IEnumerable<T> data)
        {
            return new ViewDtos<T>() { Data = data };
        }
    }

    public class ViewDtos<T> : ViewDto<IEnumerable<T>>
    {
    }

    public class ViewDto<T>:PagingData<T>,IResultState<T>
    {
        public ViewDto()
        {
            State = 1;
            Page = SiteConfig.ConfigInfo.PageNum;
            Rows = SiteConfig.ConfigInfo.PageSize;
        }
        /// <summary>
        /// 状态
        /// </summary>
        public int State { get; set; }
        
        /// <summary>
        /// 返回值描述
        /// </summary>
        public string Msg { get; set; }
    }

    public class PagingDataList<T> : PagingData<IEnumerable<T>>
    {

        public PagingDataList() { }
        public PagingDataList(QueryInfo qInfo)
        {

        }
    }
    public class ViewMdlData
    {
        public static ViewMdlData<T> Create<T>(T data)
        {
            return new ViewMdlData<T>() { Data = data };
        }
        public static ViewMdlList<T> CreateList<T>(IEnumerable<T> data, ISimplePagingInfo pagingInfo = null, ResultState resultState = null)
        {
            resultState = resultState ?? ResultState.CreateSuccess();
            return new ViewMdlList<T>(resultState) { Data = data, PagingInfo = pagingInfo };
        }
        public static ViewMdlList<T> CreateList<T>(IEnumerable<T> data, ResultState resultState)
        {
            return new ViewMdlList<T>(resultState) { Data = data, };
        }
    }
    public class ViewMdlData<T> : ResultState<T>
    {
        public ViewMdlData()
        {

        }
        public ViewMdlData(ResultState rs)
        {
            if (rs != null)
            {
                Msg = rs.Msg;
                State = rs.State;
            }

        }
        //public ResultState ResultState { get; set; }

        public ISimplePagingInfo PagingInfo { get; set; }
    }
    public class ViewMdlList<T> : ResultData<IEnumerable<T>>
    {


        public ViewMdlList(ResultState rs)
        {
            Msg = rs.Msg;
            State = rs.State;
        }
        //public ResultState ResultState { get; set; }
        //[System.Web.Script.Serialization.ScriptIgnore]
        public ISimplePagingInfo PagingInfo { get; set; }
        // public IEnumerable<T> DataList { get; set; }
    }

    public class ResultData<T> : ResultState<T>
    {

    }
}
